package com.lanswon.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lanswon.service.CoreService;

@Controller
@RequestMapping("/front/smkservice")
public class SmkServiceController {
	@Autowired
	private CoreService coreService;
	
	/**
	 * 申请页
	 * @return
	 */
	@RequestMapping("smksq")
	public String smksq(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap) {
		
		//验证用户是否登陆  未登录跳转到登陆页
		// 登陆验证
		/*if (request.getSession().getAttribute("userId") == null) {
			return "redirect:/login.html";
		}
		String userIdStr = "";*/
		Long userId = (Long) request.getSession().getAttribute("userId");
		Map<String, Object> smk = coreService.smkApplication(userId);
		modelMap.addAttribute("data", smk);
		
		return "/front/smkservice/smksq";
	}
	
	
	/**
	 * 个人申请提交 singleApplication
	 */
	/*@RequestMapping("singleApplication")
	@ResponseBody
	public Map<String, Object> singleApplication(Personal p, String cardProductCode, 
			String cardPhysicalType,String userId,HttpServletRequest request) throws ParseException, DatatypeConfigurationException {
		Map<String, Object> viewMap = new HashMap<>();
		try {
			// 登陆验证
			if (request.getSession().getAttribute("userId") == null) {
				viewMap.put("code", 1);
				viewMap.put("message", "未登录");
				return viewMap;
			}
			// 传参校验
			if (StringUtil.isEmpty(userId)||StringUtil.isEmpty(p.getPaperType())
					||StringUtil.isEmpty(p.getPaperNo())||StringUtil.isEmpty(cardProductCode)) {
				viewMap.put("code", 1);
				viewMap.put("message", "请输入参数信息");
				return viewMap;
			}
			viewMap = coreService.singleApplication(p, cardProductCode, cardPhysicalType,userId);
		} catch (Exception e) {
			e.printStackTrace();
			viewMap.put("code", 1);
			viewMap.put("message", "操作错误");
		}
		return viewMap;
	}*/
	
	/**
	 * 挂失页
	 * @return
	 */
	@RequestMapping("smkgs")
	public String smkgs(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap) {
		// 登陆验证
		if (request.getSession().getAttribute("userId") == null) {
			return "redirect:/login.html";
		}
		return "/front/smkservice/smkgs";
	}
	
	/**
	 * 交易查询
	 * @return
	 */
	@RequestMapping("jycx")
	public String jycx(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap) {
		// 登陆验证
		if (request.getSession().getAttribute("userId") == null) {
			return "redirect:/login.html";
		}
		return "/front/smkservice/jycx";
	}
	
	
	/**
	 * 服务网点
	 * @return
	 */
	@RequestMapping("fwwd")
	public String fwwd(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap) {
		
		return "/front/smkservice/fwwd";
	}
	
	@RequestMapping("smkbd")
	public String smkbd(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap) {
		
		return "/front/smkservice/smkbd";
	}
	
	
	/*@RequestMapping("detail")
	@ResponseBody
	public Map<String, Object> aboutsmkDetail(HttpServletRequest request,HttpServletResponse response,@PathVariable("articleType") Integer articleType){
		Map<String, Object> viewMap = new HashMap<>();
		try {
			viewMap.put("code", 0);
			viewMap.put("message", "查询成功");
			viewMap.put("articleType", articleType);
		} catch (Exception e) {
			e.printStackTrace();
			viewMap.put("code", 2);
			viewMap.put("message", "查询失败");
		}
		return viewMap;
	}*/
	
}
